package com.example.common.network;

import java.util.HashMap;
import java.util.Map;

public class NetworkConfig {
    
    // 多个BASE_URL配置
    public static final String API_MAIN = "main";
    public static final String API_USER = "user";
    public static final String API_ORDER = "order";
    public static final String API_PAYMENT = "payment";
    
    private static final Map<String, String> BASE_URLS = new HashMap<>();
    
    static {
        BASE_URLS.put(API_MAIN, "https://api.example.com/");
        BASE_URLS.put(API_USER, "https://user.example.com/");
        BASE_URLS.put(API_ORDER, "https://order.example.com/");
        BASE_URLS.put(API_PAYMENT, "https://payment.example.com/");
    }
    
    // 超时配置
    public static final int CONNECT_TIMEOUT = 30;
    public static final int READ_TIMEOUT = 30;
    public static final int WRITE_TIMEOUT = 30;
    
    // Header常量
    public static final String HEADER_CONTENT_TYPE = "Content-Type";
    public static final String HEADER_AUTHORIZATION = "Authorization";
    public static final String HEADER_ACCEPT = "Accept";
    public static final String HEADER_USER_AGENT = "User-Agent";
    public static final String HEADER_DEVICE_ID = "Device-Id";
    public static final String HEADER_APP_VERSION = "App-Version";
    
    // Content-Type常量
    public static final String CONTENT_TYPE_JSON = "application/json";
    public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded";
    public static final String CONTENT_TYPE_MULTIPART = "multipart/form-data";
    
    // Token前缀
    public static final String TOKEN_BEARER = "Bearer ";
    public static final String TOKEN_BASIC = "Basic ";
    
    /**
     * 获取指定API的BASE_URL
     */
    public static String getBaseUrl(String apiType) {
        return BASE_URLS.get(apiType);
    }
    
    /**
     * 获取主API的BASE_URL
     */
    public static String getMainBaseUrl() {
        return getBaseUrl(API_MAIN);
    }
    
    /**
     * 添加新的BASE_URL
     */
    public static void addBaseUrl(String apiType, String baseUrl) {
        BASE_URLS.put(apiType, baseUrl);
    }
    
    /**
     * 获取所有BASE_URL配置
     */
    public static Map<String, String> getAllBaseUrls() {
        return new HashMap<>(BASE_URLS);
    }
}